// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },

  // 模块配置
  modules: ['@nuxt/image','@pinia/nuxt'],
  // CSS配置
  css: [
    'aos/dist/aos.css',
    '@/assets/fonts/iconfont.css',
    'font-awesome/css/font-awesome.css'
  ],

  // 构建配置
  build: {
    transpile: [
    ]
  },

  // PostCSS 配置
  postcss: {
    plugins: {
      autoprefixer: {},
      'postcss-pxtorem': {
        rootValue: 16, // 根据您设置的基准值
        propList: ['*'],
        selectorBlackList: ['.no-rem'],
        minPixelValue: 1,
        mediaQuery: true,
        replace: true,
      },
    },
  },

  // 运行时配置
  runtimeConfig: {
    public: {
      apiBase: process.env.API_BASE || 'http://localhost:3000/api/v1'
    }
  },

  // 应用配置
  app: {
    head: {
      title: '游戏账号租赁平台',
      meta: [
        { charset: 'utf-8' },
        { name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' },
        { name: 'description', content: '专业的游戏账号租赁与出售平台' },
      ],
      link: [
        { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
      ]
    }
  },

  // 路由配置
  router: {
    options: {
      strict: false
    }
  },

  // 服务器配置
  server: {
    port: 3001,
    host: '0.0.0.0'
  },

  // 代理配置 - 解决跨域问题
  nitro: {
    devProxy: {
      '/api': {
        target: 'http://localhost:3000/api',
        changeOrigin: true
      },
      '/uploads': {
        target: 'http://localhost:3000',
        changeOrigin: true,
        headers: {
          'Access-Control-Allow-Origin': '*',
          'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
          'Access-Control-Allow-Headers': 'Content-Type, Authorization'
        }
      },
    }
  }
})